/**
 *
 */
package cn.hg.jfsa.web.controller;

import cn.hg.base.jfinal.controller.BaseController;

import com.jfinal.kit.Kv;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.SqlPara;

/**
 * @author Golly
 *
 */
public class IndexController extends BaseController {

	/*
	 * (non-Javadoc)
	 *
	 * @see cn.hg.base.controller.BaseController#index()
	 */
	@Override
	public void index() {
		this.setAttr("head_menu_name", "index");
		this.renderTheme("/index.html");
	}


	/**
	 * 此方法用于测试Error页面
	 */
	public void error() {
		Integer code = this.getInt("code");
		String view = this.get("view");

		if(StrKit.notBlank(view)) {
			this.renderError(code, view + ".html");
		} else {
			this.renderError(code);
		}
	}

	public void testParad() {
		String sql = "SELECT #paradef(para, 'DEFAULT VALUE') AS val, #paradef(p1, 1) AS p1, #paradef(p2, 1) AS p2";

		Kv para = Kv.by("para", this.getPara("para")).set("p1", null).set("p2", null);

		SqlPara sqlPara = Db.getSqlParaByString(sql, para);

		this.renderJson(Db.find(sqlPara));
	}

}
